package com.jbit.dm_160.service.impl;

import com.jbit.dm_160.mapper.LinkUserMapper;
import com.jbit.dm_160.model.entity.LinkUser;
import com.jbit.dm_160.service.LinkUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
@Service
public class LinkUserServiceImpl implements LinkUserService {
    @Resource
    private LinkUserMapper linkUserMapper;
    @Override
    public List<LinkUser> getLinkUsersByUserId(Integer userId) {
        return linkUserMapper.getLinkUsersByUserId(userId);
    }

    @Override
    public Boolean existsLinkUser(LinkUser linkUser) {
        return linkUserMapper.existsLinkUser(linkUser) > 0 ? true : false;
    }

    @Override
    public Integer addLinkUser(LinkUser linkUser) {
        return linkUserMapper.addLinkUser(linkUser);
    }

    @Override
    public List<LinkUser> getLinkUsersByIds(String[] linkIds) {
        Integer[] ids = new Integer[linkIds.length];
        for (int i = 0; i < linkIds.length; i++) {
            ids[i] = Integer.parseInt(linkIds[i]);
        }
        return linkUserMapper.getLinkUsersByIds(ids);
    }
}
